package com.example.aspect;

import com.example.annotation.RedisCache;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Component;

/**
 * @Author: JohnCoding
 * @Description:
 * @date: 2019/10/31 15:18
 */
@Component
@Aspect
public class RedisHandle {
    @Autowired
    RedisTemplate redisTemplate;

    @Around("@annotation(redisCache)")
    public Object aroundRedis(ProceedingJoinPoint joinPoint, RedisCache redisCache) throws Throwable {
        String value = redisCache.value();
        long expire = redisCache.expire();
        ValueOperations operations = redisTemplate.opsForValue();
        Object o = operations.get(value);
        if(o == null){

        }
        return joinPoint.proceed();
    }
}
